import SuperRouter from './superRouter.js';

export default class historyRouter extends SuperRouter{
    constructor(routerlist) {console.log(routerlist);
        super(routerlist);
        this.render(this.getPath());
        window.addEventListener('popstate', () => {
            let path = this.getPath();
            this.render(path);
        }, false)
    }
    getPath() {
        return location.pathname.substr(1);
    }
    
    push(path) {
        window.history.pushState({}, "title", `/${path}`);  
        this.render(path);
    }
    replace(path) {
        window.history.replaceState({}, "title", `/${path}`);  
        this.render(path);
    }
}